package controllers;

import helpers.HeaderHelper;

import java.io.IOException;
import java.util.Calendar;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HotlinkServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException {
		//set Header
		HeaderHelper headerHelper = new HeaderHelper();
		//Check domain exists
		response.setHeader( "Cache-Control", "public, max-age=2592000");
		response.setHeader( "Expires", new Date(Calendar.getInstance().getTime().getTime()+24*60*60*1000).toGMTString());
		
		//Set header content
		headerHelper.setTitle(request.getServerName() + " - Hotlink");
		headerHelper.setOgtitle(request.getServerName() + " - Hotlink");
		
		request.setAttribute("headerHelper", headerHelper);
		try {
			request.getRequestDispatcher("/pages/hotlink.jsp").forward(request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}